import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  BaseEntity,
  Index,
  OneToOne,
  JoinColumn,
} from 'typeorm';
import FileEntity from './file.entity';
import RoleEntity from './role.entity';

@Entity('person')
export default class PersonEntity extends BaseEntity {
  // @ApiProperty({name: 'uid', description: 'id编号'})
  @PrimaryGeneratedColumn('increment', { type: 'bigint', comment: 'id编号' })
  id: number;

  @Index()
  @Column({ length: 100, comment: '用户名' })
  userName: string;

  @Column({ nullable: true, comment: '描述' })
  description: string;

  @Column({ default: new Date().toString(), comment: '登陆时间' })
  loginTime: string;

  @Column({ type: 'int', default: 0, comment: '手机号' })
  phone: number;

  @OneToOne(type => RoleEntity, { cascade: ['update'] })
  @JoinColumn({ name: 'roleId' })
  role: RoleEntity;

  @Column({ type: 'text', comment: '用户token' })
  token: string;
}
